import {Pie} from "@ant-design/charts"

export default function PieChart(props:{data:any[]}) {
  const config = {
    width:500,
    height:400,
    data:props.data,
    angleField: 'value',
    colorField: 'name',
    legend: false,
    innerRadius: 0.6,
    labels: [
      { text: 'name', style: { fontSize: 10, fontWeight: 'bold' } },
      {
        text: (d:{value:string}, i:number, data:any[]) => (i < data.length - 3 ? d.value : ''),
        style: {
          fontSize: 9,
          dy: 12,
        },
      },
    ],
    style: {
      stroke: '#fff',
      inset: 1,
      radius: 10,
    },
    scale: {
      color: {
        palette: 'spectral',
        offset: (t:number) => t * 0.8 + 0.1,
      },
    },
  };
  return <Pie {...config} />;
}
